#include <QtCore/QString>
#include <QtTest/QtTest>
#include "../Mail/Database.h"
#include "../Mail/Settings.h"
class mailTest : public QObject
{
    Q_OBJECT
    
public:
    mailTest();
    
private Q_SLOTS:
    void test_database();
    void test_settings();
};

mailTest::mailTest()
{
}

void mailTest::test_database()
{
    Database d;

    QString account = "z@gmail.com";
    d.CreateDatabase(account);
    QStringList databaseList = d.GetDatabaseList();

    QVERIFY(true == databaseList.contains(account + ".db"));
    QVERIFY(true == d.DeleteDatabase(account));
    QVERIFY(false == d.DeleteDatabase(account));

}
void mailTest::test_settings()
{
    Settings s;

    //key
    QString key = "test_ziemek";
    QVariant value = 10;

    QVERIFY(true == s.SetValueForKey(key,value));
    QVERIFY(value == s.GetValueOfKey(key).toInt());

    s.DelKey(key);

    QVERIFY(QVariant() == s.GetValueOfKey(key));

    //password crypt
    QString email = "test@gmail.com";
    QString password = "testtest";

    QVERIFY(true == s.EncryptPassword(email,password));

    QVERIFY(password == s.DecryptPassword(email));
}

QTEST_APPLESS_MAIN(mailTest)

#include "tst_mailtest.moc"
